<?php

declare(strict_types=1);

namespace app\api\controller;

use app\repository\CouponRepository;
use think\facade\Request;
use think\facade\Db;

class Index
{
    public function index()
    {
        return '您好！这是一个[api]示例应用';
    }

    /**
     * 测试用户领券的接口
     * 测试完成后请注释！
     */
    public function testuserGetCoupon($tid, $uid)
    {
        // $CouponRepository = new CouponRepository();
        // $CouponRepository->userGetCoupon($tid, $uid);
        // return jsonData(1, 'ok');
    }

    /**
     * 获取用户信息
     */
    public function getUserInfo()
    {
        $openid = Request::header('openid');
        $user = Db::name('user')->where('wechat_openid', $openid)->find();
        $user['nickname'] = userTextDecode($user['nickname']);
        return jsonData(1, '查询成功', $user);
    }
    /**
     * 每日一言，更改为商家活动
     */
    public function yiyan()
    {
        $data = [
            "id" => 5019,
            "uuid" => "0b9533fc-3850-43f6-bb03-423a5dbf2fa5",
            "hitokoto" => "任意消费送奶茶1杯！",
            "type" => "j",
            "from" => "秦九和",
            "from_who" => "不自爱里迷失",
            "creator" => "小忧忧",
            "creator_uid" => 4701,
            "reviewer" => 4756,
            "commit_from" => "web",
            "created_at" => "1582646766",
            "length" => 20
        ];
        return jsonData(1, '请求成功', $data);
    }

    /**
     * 获取当前小程序主题颜色
     */
    public function colorTheme()
    {
        $skey = 'miniColorTheme';
        $data = sysdata($skey);
        return jsonData(1, '成功', compact('data'));
    }
}
